this.BX=this.BX||{};this.BX.Mobile=this.BX.Mobile||{};this.BX.Mobile.Field=this.BX.Mobile.Field||{};(function(t,e){"use strict";var i=window.BX,a=window.BXMobileApp;var s=function(){var t=function t(e,a,s,o){this.type=a;this.node=e;this.container=s;this.click=i.delegate(this.click,this);this.callback=i.delegate(this.callback,this);i.bind(this.container,"click",this.click);i.bind(this.container.parentNode,"click",this.click);this.format={inner:{datetime:"dd.MM.yyyy H:mm",time:"H:mm",date:"dd.MM.yyyy"},bitrix:{datetime:null,time:null,date:null},visible:{datetime:null,time:null,date:null}};this.init(o)};t.prototype={click:function t(e){i.eventCancelBubble(e);this.show();return i.PreventDefault(e)},show:function t(){var e={type:this.type,start_date:this.getStrDate(this.node.value),format:this.format.inner[this.type],callback:this.callback};if(e["start_date"]==""){delete e["start_date"]}a.UI.DatePicker.setParams(e);a.UI.DatePicker.show()},callback:function t(e){var a=this.makeDate(e);this.node.value=i.date.format(this.format.bitrix[this.type],a);var s=i.date.format(i.clone(this.format.visible[this.type]),a);if(!i.type.isNotEmptyString(s)){s=this.container.getAttribute("placeholder")||" "}this.container.innerHTML=s;if(this.delButton){this.delButton.style.display="inline-block"}i.onCustomEvent(this,"onChange",[this,this.node])},makeDate:function t(e){var a=new Date;if(i.type.isNotEmptyString(e)){var s=new RegExp("(\\d{2}).(\\d{2}).(\\d{4})"),o=new RegExp("(\\d{1,2}):(\\d{1,2})"),n;if(s.test(e)&&(n=s.exec(e))&&n){a.setDate(n[1]);a.setMonth(n[2]-1);a.setFullYear(n[3])}if(o.test(e)&&(n=o.exec(e))&&n){a.setHours(n[1]);a.setMinutes(n[2]);a.setSeconds(0)}}return a},getStrDate:function t(e){var a=i.parseDate(e),s="";if(a!==null){if(this.type=="date"||this.type=="datetime"){s=i.util.str_pad_left(a.getDate().toString(),2,"0")+"."+i.util.str_pad_left((a.getMonth()+1).toString(),2,"0")+"."+a.getFullYear().toString()}if(this.type=="datetime"){s+=" "}if(this.type=="time"||this.type=="datetime"){s+=i.util.str_pad_left(a.getHours().toString(),2,"0")+":"+a.getMinutes().toString()}}return s},init:function t(a){var s=i.date.convertBitrixFormat(e.Loc.getMessage("FORMAT_DATETIME")),o=i.date.convertBitrixFormat(e.Loc.getMessage("FORMAT_DATE")),n;if(s.substr(0,o.length)==o){n=i.util.trim(s.substr(o.length))}else{n=i.date.convertBitrixFormat(s.indexOf("T")>=0?"H:MI:SS T":"HH:MI:SS")}this.format.bitrix.datetime=s;this.format.bitrix.date=o;this.format.bitrix.time=n;a=a||{};this.format.visible.datetime=a["datetime"]||s.replace(":s","");this.format.visible.date=a["date"]||o;this.format.visible.time=a["time"]||n.replace(":s","");this.format.visible.datetime=[["today","today, "+this.format.visible.time],["tommorow","tommorow, "+this.format.visible.time],["yesterday","yesterday, "+this.format.visible.time],["",this.format.visible.datetime]];this.format.visible.date=[["today","today"],["tommorow","tommorow"],["yesterday","yesterday"],["",this.format.visible.date]];this.delButton=i("".concat(this.node.id,"_del"));if(this.delButton){i.bind(this.delButton,"click",i.proxy(this.drop,this))}},drop:function t(e){if(e){i.eventCancelBubble(e);i.PreventDefault(e)}this.node.value="";this.container.innerHTML=this.container.getAttribute("placeholder");if(this.delButton){this.delButton.style.display="none"}i.onCustomEvent(this,"onChange",[this,this.node]);return false}};return t}();window.app.exec("enableCaptureKeyboard",true);i.Mobile.Field.Datetime=function(t){this.init(t)};i.Mobile.Field.Datetime.prototype={__proto__:i.Mobile.Field.prototype,bindElement:function t(e){var a=null;if(i(e)){var o=e.hasAttribute("data-bx-type")?e.getAttribute("data-bx-type").toLowerCase():"";a=new s(e,o,i("".concat(e.id,"_container")),this.format)}return a}}})(this.BX.Mobile.Field.Datetime=this.BX.Mobile.Field.Datetime||{},BX);
//# sourceMappingURL=mobile.map.js